<?php
namespace App\Http\Controllers\Front;

use App\Services\Front\IndexService;
use Illuminate\Http\Request;

class IndexController extends BaseController
{
    public function __construct(IndexService $service)
    {
        $this->db = $service;
    }

    //已用列表
    public function usedCodeList(Request $request)
    {
        $showCode = $request->post('word', '');
        $pages['start'] = $request->post('pageStart', 0);
        $pages['limit'] = $request->post('pageLimit', 8);
        $res = $this->db->usedCodeList($pages, $showCode);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson(0, '', $res['data'], $res['total']);
    }

    //空码列表
    public function emptyList(Request $request)
    {
        $showCode = $request->post('word', '');
        $pages['start'] = $request->post('pageStart', 0);
        $pages['limit'] = $request->post('pageLimit', 8);
        $res = $this->db->emptyList($pages, $showCode);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson(0, '', $res['data'], $res['total']);
    }
}